<?php
echo html::script('media/lib/jquery-ui/js/jquery-ui-1.8.custom.min.js')."\n";
echo html::script('media/lib/el/elrte/js/elrte.full.js')."\n";
echo html::script('media/lib/el/elrte/js/i18n/elrte.pl.js')."\n";
echo html::script('media/lib/el/elfinder/js/elfinder.full.js')."\n";
echo html::script('media/lib/el/elfinder/js/i18n/elfinder.pl.js')."\n";
echo Html::style('media/lib/jquery-ui/development-bundle/themes/base/jquery.ui.all.css')."\n";
echo html::style('media/lib/el/elrte/css/elrte.full.css')."\n";
echo html::style('media/lib/el/elfinder/css/elfinder.css')."\n";
echo html::style('media/lib/uploadify/css/uploadify.css')."\n";
echo html::script('media/lib/uploadify/scripts/swfobject.js')."\n";
echo html::script('media/lib/uploadify/scripts/jquery.uploadify.v2.1.0.min.js')."\n";
?>
<?php
if($page['published'] == 1)
	$publish = 'checked';
	else $publish = '';
?>

<form method="post" action="admin/addpage/<?php echo $id ?>/">
<table border="0">
<tr><td>Tytuł</td><td></td></tr>
<tr>
<td><input type="text" size="30" name="title" value="<?php echo $page['title'] ?>" />
&nbsp;&nbsp;
<input type="checkbox" <?php echo $publish ?> value="1" name="publish" />&nbsp;&nbsp;&nbsp;Publikacja
</td>
<td></td>
</tr>
<?php if($id != 12 && $id != 13 && $id != 14): ?>
<tr>
<td>
<?php if($id != 0): ?>
<div id="photo-wrap">
	<div id="exc_photo"><?php echo html::image('upload/news/'.$page['excerpt_photo']) ?></div>
	<div id="fileQueue"></div>
</div>
<?php else: ?>
Zdjęcie skrótu możesz dodać dopiero po zapisaniu strony
<?php endif ?>
</td>
<td>
<?php if($id != 0): ?>
<div id="load-wrap">
	<div id="uploadify"></div>
</div>
<?php if($page['excerpt_photo'] != ""): ?>
<div id="del-photo-th">
	<?php echo html::anchor('admin/delthumb/'.$id,html::image('media/img/cross.png',array('alt'=>'usuń miniaturkę')),array('onclick'=>'return confirm("Na pewno usunąć?")')) ?>
</div>
<?php endif ?>
<?php endif ?>
</td>
</tr>
<tr><td>Treść skrótu</td><td></td></tr>
<tr>
	<td colspan="2">
		<div id="editor_1">
			<?php echo $page['short'] ?>	
		</div>
	</td>
</tr>
<?php endif ?>
<tr><td>Treść strony</td><td></td></tr>
<tr>
	<td colspan="2">
		<div id="editor">
			<?php echo $page['content'] ?>	
		</div>
	</td>
</tr>
<tr><td>Description</td><td></td></tr>
<tr>
	<td colspan="2">
		<textarea name="seo_description" cols="70" rows="2"><?php echo $page['seo_description'] ?></textarea>
	</td>
</tr>
<tr><td>Keywords</td><td></td></tr>
<tr>
	<td colspan="2">
		<textarea name="seo_keywords" cols="70" rows="2"><?php echo $page['seo_keywords'] ?></textarea>
	</td>
</tr>
<tr>
	<td>
		<input type="hidden" value="<?php echo $cat_check ?>" name="cat_check" />
		<input type="submit" value="zapisz" />
	</td>
	<td></td>
</tr>
</table>
</form>

<script type="text/javascript" charset="utf-8">
<!--
$().ready(function() {
	var opts = {
		cssClass : 'el-rte',
		lang     : 'pl',
		height   : 300,
		toolbar  : 'maxi',
		cssfiles : ['media/lib/el/elrte/css/elrte-inner.css'],
		fmOpen : function(callback) {
		$('<div id="myelfinder" />').elfinder({
				url : 'media/lib/el/elfinder/connectors/php/connector.php',
				lang : 'pl',
				dialog : { width : 800, modal : true, title : 'Pliki' },
				closeOnEditorCallback : true,
				editorCallback : callback
			})
		}
	}
	$('#editor').elrte(opts);
	var opts1 = {
		cssClass : 'el-rte',
		lang     : 'pl',
		height   : 150,
		toolbar  : 'compact',
		cssfiles : ['media/lib/el/elrte/css/elrte-inner.css'],
	}
	$('#editor_1').elrte(opts1);
	
	$("#uploadify").uploadify({
		'uploader'       : '<?php echo Url::base(false,true) ?>media/lib/uploadify/scripts/uploadify.swf',
		'script'         : '<?php echo Url::base(false,true) ?>uploadify/excerpt-<?php echo $id ?>',
		'cancelImg'      : '<?php echo Url::base(false,true) ?>media/lib/uploadify/cancel.png',
		'folder'         : '<?php echo Kohana::$base_url ?>upload/news/',
		'queueID'        : 'fileQueue',
		'auto'           : true,
		'buttonText'	 : 'PRZEGLADAJ',
		'fileDesc' : 'Obraz (*.jpg;*.jpeg;*.gif)',
		'fileExt' : '*.jpg;*.jpeg;*.gif',
		'sizeLimit'		 : '<?php echo Kohana::config('appconf.gallery_thumb_size') ?>',
		'width'			 : '110',
		'height'		 : '30',
		'multi'          : true,
		'onAllComplete': function(a, b, c, d, e){
                    //alert(b.toSource());
					location.reload();
                  }
	});
})
//-->
</script>